package Game;

import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Position {
	ArrayList<Position> occupiedPosition = new ArrayList<Position>();
	
	private boolean isBlank = true;
	private int x;
	private int y;
	/**
	 * Cwiartka numerujemy je
	 * 2 1
	 * 3 4
	 */
	private int quarter;
	

	private Ant ant;
	
	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public Position(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	public int getQuarter() {
		return quarter;
	}

	public void setQuarter(int quarter) {
		this.quarter = quarter;
	}


	
	public void updateBlankPosition() {
	//	occupiedPosition.put(getX(), getY());
	}

	public boolean isBlank() {
		if(getAnt() == null) {
			setBlank(true);
		}
		return isBlank;
	}

	public void setBlank(boolean isBlank) {
		this.isBlank = isBlank;
	}

	public Ant getAnt() {
		return ant;
	}

	public void setAnt(Ant ant) {
		setBlank(false);
		this.ant = ant;
	}
	
	//zwraca kolor mrowki na okreslonym polu
	public Color getAntColor(){
		if(this.isBlank()) return Color.WHITE;
		else {
			Species sp = this.getAnt().getSpecies();
			float exp = this.getAnt().getExpirence();
			exp *= 0.1f;
			exp = 0.5f - exp;			
			Color color = null;
			if(sp == Species.BLACK) color =  Color.BLUE;
			else if(sp == Species.GREEN) color = Color.GREEN;
			else if(sp == Species.YELLOW) color = Color.YELLOW;
			else if(sp == Species.RED) color = Color.RED;
			
			float[] hsbColor = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
			hsbColor[1] -= exp;
			color = new Color(Color.HSBtoRGB(hsbColor[0], hsbColor[1], hsbColor[2]));
			return color;
		}
	}
}
